home *** CD-ROM | disk | FTP | other *** search
- /******************************************************************/
- /* */
- /* TurboCAD for Windows */
- /* Copyright (c) 1993 - 2001 */
- /* International Microcomputer Software, Inc. */
- /* (IMSI) */
- /* All rights reserved. */
- /* */
- /******************************************************************/
-
- // ToolList.cpp : implementation file
- //
-
- #include "stdafx.h"
- #include "InsSmObj.h"
- #include "ToolList.h"
- #include "SdiDialog.h"
-
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
-
- /////////////////////////////////////////////////////////////////////////////
- // CExternalObjectsList
-
- CExternalObjectsList::CExternalObjectsList()
- {
- }
-
- CExternalObjectsList::~CExternalObjectsList()
- {
- }
-
-
- BEGIN_MESSAGE_MAP(CExternalObjectsList, CListBox)
- //{{AFX_MSG_MAP(CExternalObjectsList)
- ON_WM_MOUSEMOVE()
- ON_WM_LBUTTONUP()
- ON_CONTROL_REFLECT(LBN_SELCHANGE, OnSelchange)
- ON_WM_LBUTTONDOWN()
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
-
- /////////////////////////////////////////////////////////////////////////////
- // CExternalObjectsList message handlers
-
- void CExternalObjectsList::OnMouseMove(UINT nFlags, CPoint point)
- {
- // TODO: Add your message handler code here and/or call default
- if(nFlags & MK_LBUTTON)
- {
-
- int dx = m_LB_DOWNpoint.x - point.x;
- int dy = m_LB_DOWNpoint.y - point.y;
- CPoint Pt = point;
-
- if((abs(dx) > 1 || abs(dy) > 1) && m_bDrag)
- {
- // if dragging
- if (((CSdiDialog*)GetParent())->m_dwEventConnection == 0)
- {
- ((CSdiDialog*)GetParent())->ConnectEvents();
- }
- m_OldCursor = GetCursor();
- m_DragCursor = LoadCursor(AfxGetInstanceHandle( ), MAKEINTRESOURCE(IDC_CURSOR1));
- SetCursor(m_DragCursor);
- ShowCursor(TRUE);
- m_bDrag = FALSE;
- m_LB_DOWNpoint.x = -1;
- m_LB_DOWNpoint.y = -1;
- ((CSdiDialog*)GetParent())->m_DraggingMode = TRUE;
- return;
-
- }
-
- ClientToScreen(&Pt);
- CWnd *pClickWNd = WindowFromPoint(Pt);
-
- if(pClickWNd && pClickWNd != this)
- {
- pClickWNd->ScreenToClient(&Pt);
- pClickWNd->PostMessage(WM_MOUSEMOVE, nFlags, MAKELONG(Pt.x, Pt.y));
- }
- }
- }
-
-
-
- void CExternalObjectsList::OnLButtonUp(UINT nFlags, CPoint point)
- {
- CListBox::OnLButtonUp(nFlags, point);
- m_bDrag = FALSE;
-
- CPoint Pt = point;
- ClientToScreen(&Pt);
- CWnd *pClickWNd = WindowFromPoint(Pt);
-
- if(pClickWNd && pClickWNd != this)
- {
- pClickWNd->ScreenToClient(&Pt);
- pClickWNd->PostMessage(WM_LBUTTONUP, nFlags, MAKELONG(Pt.x, Pt.y));
- SetCursor(m_OldCursor);
- ShowCursor(TRUE);
- return;
- }
- else
- {
- SetCursor(m_OldCursor);
- ShowCursor(TRUE);
- }
- }
-
-
- void CExternalObjectsList::OnSelchange()
-
- {
- // TODO: Add your control notification handler code here
-
- CListBox *pList = (CListBox *) (GetParent()->GetDlgItem(IDC_EXTOBJECTSLIST));
-
- HCURSOR hOC = ::SetCursor(::LoadCursor(NULL,IDC_WAIT));
-
- int index = pList->GetCurSel();
- CString cstrSelected;
-
- pList->GetText(index, cstrSelected);
- if (m_cstrCurSelected != cstrSelected) // check if the current selection is changed
- {
- CPreviewWnd *pPreviewWnd = (CPreviewWnd *) (((CSdiDialog*)GetParent())->GetDlgItem(IDC_PREVIEW));
- pPreviewWnd->Clear();
- // make preview for just selected external object
- pPreviewWnd->DoPreview();
- m_cstrCurSelected = cstrSelected;
- pPreviewWnd->Invalidate();
- }
- ::SetCursor(hOC);
- }
-
- void CExternalObjectsList::OnLButtonDown(UINT nFlags, CPoint point)
- {
-
- BOOL ret;
-
- CListBox::OnLButtonDown(nFlags, point);
- m_bDrag = TRUE;
- m_LB_DOWNpoint.x = point.x;
- m_LB_DOWNpoint.y = point.y;
-
- CString cstrSelected;
-
- GetText(ItemFromPoint(point, ret), cstrSelected);
-
- if (m_cstrCurSelected != cstrSelected) // check if the current selection is changed
- {
- BeginWaitCursor();
- CPreviewWnd *pPreviewWnd = (CPreviewWnd *) (((CSdiDialog*)GetParent())->GetDlgItem(IDC_PREVIEW));
- pPreviewWnd->Clear();
-
- pPreviewWnd->DoPreview();
- m_cstrCurSelected = cstrSelected;
- pPreviewWnd->Invalidate();
- EndWaitCursor();
- }
- }
-